package com.xyl.services.impl;

import com.xyl.dao.ActivityMapper;
import com.xyl.entity.Activity;
import com.xyl.services.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityServiceImpl implements ActivityService {

    @Autowired
    private ActivityMapper activityMapper;

    @Override
    public int add(Activity activity) {
        return activityMapper.insert(activity);
    }

    @Override
    public List<Activity> getByUserId(Integer userId) {
        return activityMapper.selectByUserId(userId);
    }

    @Override
    public int removeByAId(Integer id) {
        return activityMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int modify(Activity activity) {
        return activityMapper.updateByPrimaryKeySelective(activity);
    }

    @Override
    public List<Activity> filterByTypeAndYear(Integer userId,String type, Integer year) {
        return activityMapper.selectByTypeAndYear(userId,type,year);
    }

    @Override
    public Integer sumScore(Integer userId) {
        return activityMapper.selectSumScore(userId);
    }
}
